package nc.tb.bc.table;
import nc.tb.pub.ref.ViewSelectRefPane;
import nc.ui.pub.bill.BillCellEditor;

public class ViewCellEditor extends BillCellEditor {
	public ViewCellEditor(final ViewSelectRefPane vsref) {
		super(vsref);
		delegate = new EditorDelegate() {
			public void setValue(Object value) {
				vsref.setValue((value != null) ? value.toString() : "");
			}

			public Object getCellEditorValue() {
				if (vsref.getSelectedBusiObj() == null)
					return vsref.getText();
				else
					return vsref.getSelectedBusiObj();
			}
		};
	}

	public java.awt.Component getTableCellEditorComponent(javax.swing.JTable table, Object value, boolean isSelected, int row, int column) {
		delegate.setValue(value);
		return editorComponent;
	}

}
